package main

import "fmt"

// printer
type Printer interface {
	PrintFile(file string) //打印文件
}
type Computer interface {
	Print(file string)
	SetPrinter(p Printer)
}

type Epson struct {
}

func (e *Epson) PrintFile(p string) {
	fmt.Println("Epson打印机打印文件:", p)
}

type Hp struct {
}

func (h *Hp) PrintFile(p string) {
	fmt.Println("惠普打印机打印文件:", p)
}

type Mac struct {
	printer Printer
}

func (m *Mac) Print(p string) {
	//电脑调用打印机的方法
	m.printer.PrintFile(p)
}
func (m *Mac) SetPrinter(p Printer) {
	m.printer = p
}

func main() {

}
